export default [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/pages/Home')
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/pages/Login'),
        meta: {
            isHidden: true
        }
    },
    {
        path: '/register',
        name: 'Register',
        component: () => import('@/pages/Register'),
        meta: {
            //不能写成isShow:false,因为其它路由没有isShow则默认为undefined，转为布尔就为false，会存在问题
            isHidden: true
        }
    },
    {
        path: '/images/:searchKey?',
        name: 'Search',
        component: () => import('@/pages/Search')
    },
    {
        path: '/detail/:skuId',
        name: 'Detail',
        component: () => import('@/pages/Detail')
    },
    {
        path: '/addCartSuccess',
        name: 'AddCartSuccess',
        component: () => import('@/pages/AddCartSuccess')
    },
    {
        path: '/shopCart',
        name: 'ShopCart',
        component: () => import('@/pages/ShopCart')
    },
    {
        path: '/trade',
        name: 'Trade',
        component: () => import('@/pages/Trade'),
        beforeEnter: (to, from, next) => {
            if (from.name !== 'ShopCart') return next('/shopCart')
            next()
        }
    },
    {
        path: '/pay',
        name: 'Pay',
        component: () => import('@/pages/Pay'),
        beforeEnter: (to, from, next) => {
            if (from.name !== 'Trade') return next('/shopCart')
            next()
        }
    },
    {
        path: '/paySuccess',
        name: 'PaySuccess',
        component: () => import('@/pages/PaySuccess'),
        beforeEnter: (to, from, next) => {
            if (from.name !== 'Pay') return next('/shopCart')
            next()
        }
    },
    {
        path: '/center',
        redirect: '/center/myOrder',
        component: () => import('@/pages/Center'),
        children: [
            {
                path: 'myOrder',
                name: 'MyOrder',
                component: () => import('@/pages/Center/MyOrder')
            },
            {
                path: 'tempOrder',
                name: 'TempOrder',
                component: () => import('@/pages/Center/TempOrder')
            }
        ]
    },
    {
        path: '*',
        name: 'NotFound',

    }
]